package com.wwl.cms.basic.utils;

import lombok.Data;
import org.apache.http.HttpStatus;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @author wwl
 * @version 1.0
 * @date 2021/4/30 16:44
 * @description:
 */
@Data
public class R<T>  implements Serializable {

    private int status;
    private String message;
    private T data;

    public R( int status,String message, T data) {
        this.message = message;
        this.status = status;
        this.data = data;
    }

    public R( int status,String message) {
        this.message = message;
        this.status = status;
    }

    public R(T data) {
        this.data = data;
    }

    public static R error() {
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常，请联系管理员");
    }

    public static R error(String msg) {
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
    }

    public static R error(int status, String msg) {
        return new R(status,msg);
    }

    public static R ok() {
        return new R(0,"请求成功!");
    }
    public  R ok(T data) {
        return new R(0,"请求成功!",data);
    }

}
